/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-10-19
*/
package com.rzico.business.controller.admin;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rzico.annotation.Log;
import com.rzico.base.BaseController;
import com.rzico.base.CommResult;
import com.rzico.entity.Filter;
import com.rzico.entity.Pageable;
import com.rzico.entity.PageResult;
import com.rzico.business.entity.CdfxInfo;
import com.rzico.business.service.CdfxInfoService;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.Api;
import com.rzico.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;

/**
 * 车道方向信息控制层
 *
 * @author Rzico Boot
 * @version 1.0
 * @date 2020-10-19
 */
@Api(description = "车道方向信息接口")
@RestController
@RequestMapping("/admin/cdfxInfo")
public class CdfxInfoController extends BaseController {

    @Autowired
    private CdfxInfoService cdfxInfoService;

    /**
     * 分页查询车道方向信息
     *
     * @return
    */
    @ApiOperation("分页查询车道方向信息")
    @GetMapping("/list")
    @ApiImplicitParams({@ApiImplicitParam(name = "kkbh", value = "卡号编号", dataType = "String", paramType = "query") ,
            @ApiImplicitParam(name = "cdbh", value = "车道编号", dataType = "String", paramType = "query")
    })
    public CommResult<CdfxInfo> list(String kkbh, String cdbh, Pageable pageable) {
        Map<String, Object> params = new HashMap<String, Object>();
        params = buildSortField(params, pageable);
        if (kkbh!=null){
           params.put("kkbh", kkbh);
        }
        if (cdbh!=null){
            params.put("cdbh", cdbh);
        }


        Page<Object> startPage = PageHelper.startPage(pageable.getPageNum(), pageable.getPageSize());
        List<CdfxInfo> list = cdfxInfoService.selectList(params);
        PageResult<CdfxInfo> pageResult = new PageResult<CdfxInfo>(list, startPage.getTotal(), pageable);
        return CommResult.success(pageResult);
    }

    /**
     * 查询单条车道方向信息
     *
     * @return
    */
    @ApiOperation("查询单条车道方向信息")
    @GetMapping("/find/{id}")
    public CommResult<CdfxInfo> find(@PathVariable String id) {
        CdfxInfo result = cdfxInfoService.selectByPrimaryKey(id);

        Map<String,Object> data = new HashMap<>();
        data.put("cdfxInfo",result);
        return CommResult.success(data);

    }

}
